<template>
	<view class="pad-16r">
		<view class="tcard" v-for="(item,index) in paperList" :key="index" @click="toPaper(item)">
			<view>
				<view>{{item.name}}</view>
				<view class="describe">{{item.describe}}</view>
			</view>
			<view class="tip" :class="{nofill: item.surveyAnswerStatus != 1}" v-if="item.surveyAnswerId">
				{{ item.surveyAnswerStatus == 1? '已填写': '未完成' }}
			</view>
			<view class="tip" :class="{nofinish: item.surveyAnswerStatus != 1}" v-else>未填写</view>
		</view>
	</view>
</template>
<script>
	import {
		mapGetters
	} from 'vuex';
	import {
		surveySelect
	} from '../../../api/survey';
	import dayjs from 'dayjs'
	export default {

		data() {
			return {
				load: true,
				paperList: []
			};
		},
		computed: {
			...mapGetters(['userInfo']),
		},
		created() {
			this.initData()

		},
		methods: {
			initData() {
				let info = {
					patId: this.userInfo.patId
				}
				if (!this.userInfo.patId) {
					return
				}
				surveySelect(info).then(res => {
					console.log(res)
					this.paperList = res
				})
			},
			toPaper(item) {
				uni.navigateTo({
					url: `/pages/tabBar/Questionnaire/Detail?item=` + JSON.stringify(item)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tcard {
		padding: 42upx;
		position: relative;
		font-family: PingFang SC, PingFang SC;
		font-weight: 600;
		font-size: 28upx;
		color: rgba(0, 0, 0, 0.7);
	}

	.describe {
		color: gray;
		font-size: 12px;
	}

	.tip {
		width: 120upx;
		height: 48upx;
		position: absolute;
		top: 0;
		right: 0;
		line-height: 48upx;
		text-align: center;
		color: #FFF;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 24upx;
		background: #3E81F7;
		border-radius: 0px 8upx 0px 8upx;

		&.nofill {
			background-color: #5DD2B1;
		}

		&.nofinish {
			background-color: #c7d2b6;
		}
	}
</style>